﻿

Public Class ZipSettings
    'Shared :
    Public Shared Property Defaults As ZipSettings
    Shared Sub New()
        Defaults = New ZipSettings
    End Sub
    'Ctor :
    Public Sub New()
        Compression = New Compression
        Buffering = New Buffering
        Protection = New Protection
        Splitting = New Splitting
        SfxOptions = New SfxOptions
        Comment = New Comment
    End Sub
    'Fields :
    Public Property Compression As Compression
    Public Property Buffering As Buffering
    Public Property Protection As Protection
    Public Property Splitting As Splitting
    Public Property SfxOptions As SfxOptions
    Public Property Comment As Comment
    'Routines :
    Public Sub Reset()
        Compression.Reset()
        Buffering.Reset()
        Protection.Reset()
        Splitting.Reset()
        SfxOptions.Reset()
        Comment.Reset()
    End Sub
    Public Sub Reset(ByVal propname As String)
        Select Case propname
            Case "Compression"
                Me.Compression.Reset()
            Case "Buffering"
                Me.Buffering.Reset()
            Case "Protection"
                Me.Protection.Reset()
            Case "Splitting"
                Me.Splitting.Reset()
            Case "SfxOptions"
                Me.SfxOptions.Reset()
            Case "Comment"
                Me.Comment.Reset()
        End Select
    End Sub
    Public Sub CopyFrom(ByVal zipsets As ZipSettings)
        Me.Compression.CopyFrom(zipsets.Compression)
        Me.Buffering.CopyFrom(zipsets.Buffering)
        Me.Protection.CopyFrom(zipsets.Protection)
        Me.Splitting.CopyFrom(zipsets.Splitting)
        Me.SfxOptions.CopyFrom(zipsets.SfxOptions)
        Me.Comment.CopyFrom(zipsets.Comment)
    End Sub
    Public Sub ApplyToZip(ByVal zipfile As Zip.ZipFile)
        Me.Compression.ApplyToZip(zipfile)
        Me.Buffering.ApplyToZip(zipfile)
        Me.Protection.ApplyToZip(zipfile)
        Me.Comment.ApplyToZip(zipfile, Me.Infos)
    End Sub
    Public Function MakeEntrySettings() As EntrySettings
        Dim es As New EntrySettings
        es.Method = Me.Compression.Method
        es.Level = Me.Compression.Level
        es.Encryption = Me.Protection.Encryption
        es.Password = Me.Protection.Password
        Return es
    End Function
    Public Function Infos() As String
        Dim sb As New System.Text.StringBuilder
        sb.AppendLine(Me.Compression.Infos)
        sb.AppendLine(Me.Buffering.Infos)
        sb.AppendLine(Me.Protection.Infos)
        Return sb.ToString
    End Function
End Class